package demo1;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        // 1:实例化Person并调用sayHello

        Person p = new Person();
        p.sayHello();

        //2.反射调用
        Class cls = Class.forName("demo1.Person");
        Person p1 =(Person)cls.newInstance();
        p1.sayHello();

        //3.spring 容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("demo1");
        Person p2 =context.getBean(Person.class);
        p2.sayHello();
    }
}
